<?php
/**
 * 后台管理员操作日志
 */
class osgh_admin_log_tbl_cls extends pl_db_opt_cls
{
	/*
	 * 构造函数
	 */
	public function __construct()
	{
		global $_db_name;
		$this->setDbName($_db_name);
		$this->setTblName('osgh_admin_log_tbl');
	}
	
	/*
	 * 添加操作日志
	 *
	 * @param array $data
	 * @return int
	 */
	public function addMcLog($data)
	{
		return $this->insert($data, 'IGNORE');
	}
	
	/**
	 * 添加操作日志
	 * @param array $data
	 */
	public static function add($data)
	{
		$log_obj = new osgh_admin_log_tbl_cls();
		return $log_obj -> addMcLog($data);
	}
	
	/**
	 * 获取操作日志列表
	 * 
	 * @param bool $b_select_count
	 * @param string $where_str    查询条件
	 * @param string $order_by
	 * @param string $limit
	 * @return array
	 */
	public function getMcLogList($b_select_count = false, $where_str = '', $order_by = '', $limit = '')
	{
		$sql = "SELECT * FROM {$this->db_name}.{$this->tbl_name}";
		
		$sql_where = '';
		$sql_where_sp = '';
		
		if( strlen($where_str) > 0 )
		{
			$sql_where_sp = strlen($sql_where)>0?' AND ':'';
			$sql_where = $sql_where . $sql_where_sp . $where_str;
		}
		
		if ( strlen($sql_where) > 0 )
		{
			$sql .= " WHERE " . $sql_where;
		}
		
		if ( $b_select_count == true )
		{
			//统计记录数
			$tmp = $this->getList($b_select_count, $sql);
			return $tmp;
		}
		
		return $this->getList($b_select_count, $sql, $order_by, $limit);
	}
}
?>